<?php

/**
 * Description of customResolution
 *
 * @author hodek
 */
class ResolutionImp extends ResolutionAbstract {

    //put your code here

    function handle() {
        if ($_POST["actionLogin"]) {
            UserFunc::login($_POST["login"], $_POST["pass"]);
            unset($_GET["login"]);
            header("location: " . Settings::$contextPath . Settings::$defaultPage);
        }
    }

    function handleForm() {
        foreach (array_keys($_POST) as $postKey) {
            if ($postKey == "responseType") {
                continue;
            }
            if ($postKey == "delete") {
                deleteItem($_POST["delete"]);
                continue;
            }
            $neco = selectValueFromAll($postKey);
            $row = fetch($neco);
            $table = $row["tableName"];
            if ($table != null) {
                if ($table == "date") {
                    if (trim($_POST[$postKey]) != "") {
                        updateData($table, $postKey, webDateToDBDate($_POST[$postKey]));
                    }
                } else {
                    updateData($table, $postKey, urldecode($_POST[$postKey]));
                }
            }
        }
    }

    function handleAjax() {
        if (isAdmin() && $_GET["ajax"] == "uploadCismap") {
            $allowedExtensions = array("jpeg", "jpg", "png");
            $sizeLimit = 1.5 * 1024 * 1024;
            $imageName = genName();
            insertDynCisMapSimple($_GET["id"], $imageName);
            setImageUploadName($imageName);
            $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
            $result = $uploader->handleUpload();
            $result["idcismap"] = $_GET["id"];
            echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
            return;
        }
        if (isAdmin() && $_GET["ajax"] == "loadAdminImages") {
            $temp = "";
            $result = selectDyncismap($_GET["idcismap"]);
            if ($result && mysql_num_rows($result) > 0) {
                while ($row = mysql_fetch_array($result)) {
                    $temp .= AdminForms::getFFimageShowAndDelete($row["fkname"]);
                }
            }
            echo $temp;
            return;
        }
        if (isAdmin() && $_GET["ajax"] == "addCat" && isset($_GET["catName"])) {
            addCat($_GET["catName"]);
            return;
        }
        if (isAdmin() && $_GET["ajax"] == "visibilityCat" && isset($_GET["numberName"]) && isset($_GET["visiblityData"])) {
            if ($_GET["visiblityData"] == 0) {
                $newData = 1;
            } else {
                $newData = 0;
            }
            updateData("number", $_GET["numberName"], $newData);
            return;
        }
        if (isAdmin() && $_GET["ajax"] == "deleteImage") {
            deleteSometing($_GET["imageName"]);
            deleteDynCisMap($_GET["imageName"]);
        }
    }

}

?>
